package asa;

/**
 * 	Repita ::= "repita" Expr
                	StatList

 * @author José
 *
 */

public class RepitaStat extends Statement {

	public RepitaStat(Expr expr, CompositeStatement compositeStatement) {
		this.expr = expr;
		this.compositeStatement = compositeStatement;
	}
    @Override
	public void genJava(PWInterface pw) {
		genJava(pw, null);
	}
	@Override
	public void genJava(PWInterface pw, Env env) {
		String varName = env.nextTmpVariable();
		pw.printIdent("int " + varName + " = ");
		expr.genJava(pw);
		pw.println(";");
		pw.printIdent( "while ( " + varName + "-- ) ");
    	compositeStatement.genJava(pw, null);
	}

	private Expr expr;
	private CompositeStatement compositeStatement;

}
